%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/conditions/basics-with-author"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 9, 10, 44, 45, 46, 11, 13, 28<br />2: PgSelect[8]<br />3: PgSelectRows[14]"):::bucket
    Bucket1("Bucket 1 (listItem)<br />Deps: 11, 44, 28<br /><br />ROOT __Item{1}ᐸ14ᐳ[15]"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 16, 11, 44, 28<br /><br />ROOT PgSelectSingle{1}ᐸforumsᐳ[16]<br />1: <br />ᐳ: 17, 20, 25<br />2: PgSelect[21]<br />3: PgSelectRows[29]"):::bucket
    Bucket3("Bucket 3 (listItem)<br />Deps: 11<br /><br />ROOT __Item{3}ᐸ29ᐳ[30]"):::bucket
    Bucket4("Bucket 4 (nullableBoundary)<br />Deps: 31, 11<br /><br />ROOT PgSelectSingle{3}ᐸmessagesᐳ[31]<br />1: <br />ᐳ: 32, 33<br />2: PgSelect[34]<br />3: PgSelectRows[39]<br />ᐳ: First[38], PgSelectSingle[40]"):::bucket
    Bucket5("Bucket 5 (nullableBoundary)<br />Deps: 40<br /><br />ROOT PgSelectSingle{4}ᐸusersᐳ[40]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket2
    Bucket2 --> Bucket3
    Bucket3 --> Bucket4
    Bucket4 --> Bucket5

    %% plan dependencies
    PgSelect8[["PgSelect[8∈0] ➊<br />ᐸforumsᐳ<br />More deps:<br />- Object[11]"]]:::plan
    Lambda13{{"Lambda[13∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[ undefined, 'YES' ]ᐳ[46]"}}:::plan
    Lambda13 --> PgSelect8
    Object11{{"Object[11∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ<br />Dependents: 3"}}:::plan
    Access9{{"Access[9∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access10{{"Access[10∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access9 & Access10 --> Object11
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access9
    __Value2 --> Access10
    PgSelectRows14[["PgSelectRows[14∈0] ➊"]]:::plan
    PgSelect8 --> PgSelectRows14
    Lambda28{{"Lambda[28∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[HIDDEN]ᐳ[45]"}}:::plan
    __Item15[/"__Item[15∈1]<br />ᐸ14ᐳ"\]:::itemplan
    PgSelectRows14 ==> __Item15
    PgSelectSingle16{{"PgSelectSingle[16∈1]<br />ᐸforumsᐳ"}}:::plan
    __Item15 --> PgSelectSingle16
    PgSelect21[["PgSelect[21∈2]<br />ᐸmessagesᐳ<br />More deps:<br />- Object[11]<br />- Constantᐸ2ᐳ[44]"]]:::plan
    PgClassExpression20{{"PgClassExpression[20∈2]<br />ᐸ__forums__.”id”ᐳ"}}:::plan
    PgClassExpression25{{"PgClassExpression[25∈2]<br />ᐸ__forums__...chived_at”ᐳ"}}:::plan
    PgClassExpression20 & PgClassExpression25 & Lambda28 --> PgSelect21
    PgClassExpression17{{"PgClassExpression[17∈2]<br />ᐸ__forums__.”name”ᐳ"}}:::plan
    PgSelectSingle16 --> PgClassExpression17
    PgSelectSingle16 --> PgClassExpression20
    PgSelectSingle16 --> PgClassExpression25
    PgSelectRows29[["PgSelectRows[29∈2]"]]:::plan
    PgSelect21 --> PgSelectRows29
    __Item30[/"__Item[30∈3]<br />ᐸ29ᐳ"\]:::itemplan
    PgSelectRows29 ==> __Item30
    PgSelectSingle31{{"PgSelectSingle[31∈3]<br />ᐸmessagesᐳ"}}:::plan
    __Item30 --> PgSelectSingle31
    PgSelect34[["PgSelect[34∈4]<br />ᐸusersᐳ<br />More deps:<br />- Object[11]"]]:::plan
    PgClassExpression33{{"PgClassExpression[33∈4]<br />ᐸ__messages...author_id”ᐳ"}}:::plan
    PgClassExpression33 --> PgSelect34
    PgClassExpression32{{"PgClassExpression[32∈4]<br />ᐸ__messages__.”body”ᐳ"}}:::plan
    PgSelectSingle31 --> PgClassExpression32
    PgSelectSingle31 --> PgClassExpression33
    First38{{"First[38∈4]"}}:::plan
    PgSelectRows39[["PgSelectRows[39∈4]"]]:::plan
    PgSelectRows39 --> First38
    PgSelect34 --> PgSelectRows39
    PgSelectSingle40{{"PgSelectSingle[40∈4]<br />ᐸusersᐳ"}}:::plan
    First38 --> PgSelectSingle40
    PgClassExpression41{{"PgClassExpression[41∈5]<br />ᐸ__users__.”username”ᐳ"}}:::plan
    PgSelectSingle40 --> PgClassExpression41
    PgClassExpression42{{"PgClassExpression[42∈5]<br />ᐸ__users__....vatar_url”ᐳ"}}:::plan
    PgClassExpression41 o--o PgClassExpression42

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect8,Access9,Access10,Object11,Lambda13,PgSelectRows14,Lambda28 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,__Item15,PgSelectSingle16 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,PgClassExpression17,PgClassExpression20,PgSelect21,PgClassExpression25,PgSelectRows29 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3,__Item30,PgSelectSingle31 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4,PgClassExpression32,PgClassExpression33,PgSelect34,First38,PgSelectRows39,PgSelectSingle40 bucket4
    classDef bucket5 stroke:#7fff00
    class Bucket5,PgClassExpression41,PgClassExpression42 bucket5

